<?php
	// start the session
  	session_start();

	// include the EC2 and S3 libraries
  	require_once("class.ec2.php");
  	require_once("class.s3.php");
  
	// create session variables for AWS keys
  	session_register("AMAZON_KEY");
  	session_register("AMAZON_PRIVATE_KEY");

	// is this a self post back?
  	if (!isset($_POST['submit'])) {
		// retrieve defaults
      	$HTTP_SESSION_VARS["AMAZON_KEY"] = "<ENTER YOUR KEY HERE>";
      	$HTTP_SESSION_VARS["AMAZON_PRIVATE_KEY"] = "<ENTER YOUR PRIVATE KEY HERE>";
  	} else {
		// retrieve posted values
      	$HTTP_SESSION_VARS["AMAZON_KEY"] = $_POST["accessKey"];
      	$HTTP_SESSION_VARS["AMAZON_PRIVATE_KEY"] = $_POST["secretKey"];
  	}
?>
<!-- *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+ -->
<!-- File: Index.php 																							-->
<!--																											-->
<!-- Author: John Fronckowiak, IDC Consulting, Inc.																-->
<!--																											-->
<!-- Purpose: The iPhone AWS Manager 																			-->
<!-- *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+ -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<!-- set the iPhone viewport -->
	<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
	
	<!-- include the iui style sheet and javascript -->
	<style type="text/css" media="screen">@import "lib/iui/iui.css";</style>
    <script type="application/x-javascript" src="lib/iui/iui.js"></script>		

	<title>Amazon Web Services Manager</title>
</head>

<body>
	<!-- create the primary toolbar -->
    <div class="toolbar">
        <h1 id="pageTitle"></h1>
        <a id="backButton" class="button" href="#"></a>
    </div>  

	<!-- create the main menu -->
    <ul id="home" title="AWS Manager" selected="true">
       <li class="group">Settings</li>
       <li><a href="#creds">Set Credentials</a></li>
       <li class="group">EC2 Management</li>
       <li><a href="amis.php">Available AMIs</a></li>
       <li><a href="instances.php">Your Instances</a></li>
       <li class ="group">S3 Management</li>
       <li><a href="getbuckets.php">Available Buckets</a></li>
       <li><a href="#bucket">Create Bucket</a></li>
       <li class="group">About</li>
       <li><a href="about.php">About</a></li>
    </ul>

	<!-- the credentials form -->
    <form id="creds" class="dialog" action="<?php echo $PHP_SELF; ?>" method="POST">
       <fieldset>
           <h1>Set Credentials</h1>
           <a class="button leftButton" type="cancel">Cancel</a>
           <a class="button blueButton" type="submit">Save</a>           
           <label>Key:</label>
           <input type="text" name="accessKey" value="<?php echo $HTTP_SESSION_VARS["AMAZON_KEY"]; ?>"/>
           <label>Secret:</label>
           <input type="text" name="secretKey"/>
        </fieldset>
     </form>

    <!-- the create bucket form -->
     <form id="bucket" class="dialog" action="create.php" method="POST">
        <fieldset>
            <h1>Create Bucket</h1>
            <a class="button leftButton" type="cancel">Cancel</a>
            <a class="button blueButton" type="submit">Create</a>           
            <label>Name:</label>
            <input type="text" name="bucketName"/>
        </fieldset>
     </form>
       
</body>
</html>